home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / X11R4 / cmds / X / dix / swaprep.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-02-14  |  36.0 KB  |  1,373 lines

  1. /************************************************************
  2. Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
  3. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  4.  
  5.                         All Rights Reserved
  6.  
  7. Permission to use, copy, modify, and distribute this software and its 
  8. documentation for any purpose and without fee is hereby granted, 
  9. provided that the above copyright notice appear in all copies and that
  10. both that copyright notice and this permission notice appear in 
  11. supporting documentation, and that the names of Digital or MIT not be
  12. used in advertising or publicity pertaining to distribution of the
  13. software without specific, written prior permission.  
  14.  
  15. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  16. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  17. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  18. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  19. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  20. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  21. SOFTWARE.
  22.  
  23. ********************************************************/
  24.  
  25. /* $XConsortium: swaprep.c,v 1.36 89/07/03 19:50:49 rws Exp $ */
  26.  
  27. #include "X.h"
  28. #define NEED_REPLIES
  29. #define NEED_EVENTS
  30. #include "Xproto.h"
  31. #include "misc.h"
  32. #include "dixstruct.h"
  33. #include "fontstruct.h"
  34. #include "scrnintstr.h"
  35.  
  36. void SwapVisual(), SwapConnSetup(), SwapWinRoot();
  37.  
  38. /* Thanks to Jack Palevich for testing and subsequently rewriting all this */
  39. void
  40. Swap32Write(pClient, size, pbuf)
  41.     ClientPtr    pClient;
  42.     int        size;  /* in bytes */
  43.     register long *pbuf;
  44. {
  45.     int        n, i;
  46.  
  47.     size >>= 2;
  48.     for(i = 0; i < size; i++)
  49.     /* brackets are mandatory here, because "swapl" macro expands
  50.        to several statements */
  51.     {   
  52.     swapl(&pbuf[i], n);
  53.     }
  54.     (void)WriteToClient(pClient, size << 2, (char *) pbuf);
  55. }
  56.  
  57. void
  58. CopySwap32Write(pClient, size, pbuf)
  59.     ClientPtr    pClient;
  60.     int        size;   /* in bytes */
  61.     long    *pbuf;
  62. {
  63.     int bufsize = size;
  64.     long *pbufT;
  65.     register long *from, *to, *fromLast, *toLast;
  66.     long tmpbuf[1];
  67.     
  68.     /* Allocate as big a buffer as we can... */
  69.     while (!(pbufT = (long *) ALLOCATE_LOCAL(bufsize)))
  70.     {
  71.         bufsize >>= 1;
  72.     if (bufsize == 4)
  73.     {
  74.         pbufT = tmpbuf;
  75.         break;
  76.     }
  77.     }
  78.     
  79.     /* convert lengths from # of bytes to # of longs */
  80.     size >>= 2;
  81.     bufsize >>= 2;
  82.  
  83.     from = pbuf;
  84.     fromLast = from + size;
  85.     while (from < fromLast) {
  86.     int nbytes;
  87.         to = pbufT;
  88.         toLast = to + min (bufsize, fromLast - from);
  89.         nbytes = (toLast - to) << 2;
  90.         while (to < toLast) {
  91.             /* can't write "cpswapl(*from++, *to++)" because cpswapl is a macro
  92.            that evaulates its args more than once */
  93.         cpswapl(*from, *to);
  94.             from++;
  95.             to++;
  96.         }
  97.     (void)WriteToClient (pClient, nbytes, (char *) pbufT);
  98.     }
  99.  
  100.     if (pbufT != tmpbuf)
  101.     DEALLOCATE_LOCAL ((char *) pbufT);
  102. }
  103.  
  104. void
  105. CopySwap16Write(pClient, size, pbuf)
  106.     ClientPtr    pClient;
  107.     int        size;   /* in bytes */
  108.     short    *pbuf;
  109. {
  110.     int bufsize = size;
  111.     short *pbufT;
  112.     register short *from, *to, *fromLast, *toLast;
  113.     short tmpbuf[2];
  114.     
  115.     /* Allocate as big a buffer as we can... */
  116.     while (!(pbufT = (short *) ALLOCATE_LOCAL(bufsize)))
  117.     {
  118.         bufsize >>= 1;
  119.     if (bufsize == 4)
  120.     {
  121.         pbufT = tmpbuf;
  122.         break;
  123.     }
  124.     }
  125.     
  126.     /* convert lengths from # of bytes to # of shorts */
  127.     size >>= 1;
  128.     bufsize >>= 1;
  129.  
  130.     from = pbuf;
  131.     fromLast = from + size;
  132.     while (from < fromLast) {
  133.     int nbytes;
  134.         to = pbufT;
  135.         toLast = to + min (bufsize, fromLast - from);
  136.         nbytes = (toLast - to) << 1;
  137.         while (to < toLast) {
  138.             /* can't write "cpswaps(*from++, *to++)" because cpswaps is a macro
  139.            that evaulates its args more than once */
  140.         cpswaps(*from, *to);
  141.             from++;
  142.             to++;
  143.         }
  144.     (void)WriteToClient (pClient, nbytes, (char *) pbufT);
  145.     }
  146.  
  147.     if (pbufT != tmpbuf)
  148.     DEALLOCATE_LOCAL ((char *) pbufT);
  149. }
  150.  
  151.  
  152. /* Extra-small reply */
  153. void
  154. SGenericReply(pClient, size, pRep)
  155.     ClientPtr            pClient;
  156.     int                size;
  157.     xGenericReply        *pRep;
  158. {
  159.     int n;
  160.  
  161.     swaps(&pRep->sequenceNumber, n);
  162.     (void)WriteToClient(pClient, size, (char *) pRep);
  163. }
  164.  
  165. /* Extra-large reply */
  166. void
  167. SGetWindowAttributesReply(pClient, size, pRep)
  168.     ClientPtr            pClient;
  169.     int                size;
  170.     xGetWindowAttributesReply    *pRep;
  171. {
  172.     int n;
  173.  
  174.     swaps(&pRep->sequenceNumber, n);
  175.     swapl(&pRep->length, n);
  176.     swapl(&pRep->visualID, n);
  177.     swaps(&pRep->class, n);
  178.     swapl(&pRep->backingBitPlanes, n);
  179.     swapl(&pRep->backingPixel, n);
  180.     swapl(&pRep->colormap, n);
  181.     swapl(&pRep->allEventMasks, n);
  182.     swapl(&pRep->yourEventMask, n);
  183.     swaps(&pRep->doNotPropagateMask, n);
  184.     (void)WriteToClient(pClient, size, (char *) pRep);
  185. }
  186.  
  187. void
  188. SGetGeometryReply(pClient, size, pRep)
  189.     ClientPtr        pClient;
  190.     int            size;
  191.     xGetGeometryReply    *pRep;
  192. {
  193.     int n;
  194.  
  195.     swaps(&pRep->sequenceNumber, n);
  196.     swapl(&pRep->root, n);
  197.     swaps(&pRep->x, n);
  198.     swaps(&pRep->y, n);
  199.     swaps(&pRep->width, n);
  200.     swaps(&pRep->height, n);
  201.     swaps(&pRep->borderWidth, n);
  202.     (void)WriteToClient(pClient, size, (char *) pRep);
  203. }
  204.  
  205. void
  206. SQueryTreeReply(pClient, size, pRep)
  207.     ClientPtr        pClient;
  208.     int            size;
  209.     xQueryTreeReply    *pRep;
  210. {
  211.     int n;
  212.  
  213.     swaps(&pRep->sequenceNumber, n);
  214.     swapl(&pRep->length, n);
  215.     swapl(&pRep->root, n);
  216.     swapl(&pRep->parent, n);
  217.     swaps(&pRep->nChildren, n);
  218.     (void)WriteToClient(pClient, size, (char *) pRep);
  219. }
  220.  
  221. void
  222. SInternAtomReply(pClient, size, pRep)
  223.     ClientPtr        pClient;
  224.     int            size;
  225.     xInternAtomReply    *pRep;
  226. {
  227.     int n;
  228.  
  229.     swaps(&pRep->sequenceNumber, n);
  230.     swapl(&pRep->atom, n);
  231.     (void)WriteToClient(pClient, size, (char *) pRep);
  232. }
  233.  
  234. void
  235. SGetAtomNameReply(pClient, size, pRep)
  236.     ClientPtr            pClient;
  237.     int                size;
  238.     xGetAtomNameReply    *pRep;
  239. {
  240.     int n;
  241.  
  242.     swaps(&pRep->sequenceNumber, n);
  243.     swapl(&pRep->length, n);
  244.     swaps(&pRep->nameLength, n);
  245.     (void)WriteToClient(pClient, size, (char *) pRep);
  246. }
  247.  
  248.  
  249. void
  250. SGetPropertyReply(pClient, size, pRep)
  251.     ClientPtr            pClient;
  252.     int                size;
  253.     xGetPropertyReply    *pRep;
  254. {
  255.     int n;
  256.  
  257.     swaps(&pRep->sequenceNumber, n);
  258.     swapl(&pRep->length, n);
  259.     swapl(&pRep->propertyType, n);
  260.     swapl(&pRep->bytesAfter, n);
  261.     swapl(&pRep->nItems, n);
  262.     (void)WriteToClient(pClient, size, (char *) pRep);
  263. }
  264.  
  265. void
  266. SListPropertiesReply(pClient, size, pRep)
  267.     ClientPtr            pClient;
  268.     int                size;
  269.     xListPropertiesReply    *pRep;
  270. {
  271.     int n;
  272.  
  273.     swaps(&pRep->sequenceNumber, n);
  274.     swapl(&pRep->length, n);
  275.     swaps(&pRep->nProperties, n);
  276.     (void)WriteToClient(pClient, size, (char *) pRep);
  277. }
  278.  
  279. void
  280. SGetSelectionOwnerReply(pClient, size, pRep)
  281.     ClientPtr            pClient;
  282.     int                size;
  283.     xGetSelectionOwnerReply    *pRep;
  284. {
  285.     int n;
  286.  
  287.     swaps(&pRep->sequenceNumber, n);
  288.     swapl(&pRep->owner, n);
  289.     (void)WriteToClient(pClient, size, (char *) pRep);
  290. }
  291.  
  292.  
  293. void
  294. SQueryPointerReply(pClient, size, pRep)
  295.     ClientPtr        pClient;
  296.     int            size;
  297.     xQueryPointerReply    *pRep;
  298. {
  299.     int n;
  300.  
  301.     swaps(&pRep->sequenceNumber, n);
  302.     swapl(&pRep->root, n);
  303.     swapl(&pRep->child, n);
  304.     swaps(&pRep->rootX, n);
  305.     swaps(&pRep->rootY, n);
  306.     swaps(&pRep->winX, n);
  307.     swaps(&pRep->winY, n);
  308.     swaps(&pRep->mask, n);
  309.     (void)WriteToClient(pClient, size, (char *) pRep);
  310. }
  311.  
  312. void
  313. SwapTimeCoordWrite(pClient, size, pRep)
  314.     ClientPtr            pClient;
  315.     int                size;
  316.     xTimecoord            *pRep;
  317. {
  318.     int    i, n;
  319.     xTimecoord            *pRepT;
  320.  
  321.     n = size / sizeof(xTimecoord);
  322.     pRepT = pRep;
  323.     for(i = 0; i < n; i++)
  324.     {
  325.     SwapTimecoord(pRepT);
  326.     pRepT++;
  327.     }
  328.     (void)WriteToClient(pClient, size, (char *) pRep);
  329.  
  330. }
  331. void
  332. SGetMotionEventsReply(pClient, size, pRep)
  333.     ClientPtr            pClient;
  334.     int                size;
  335.     xGetMotionEventsReply    *pRep;
  336. {
  337.     int n;
  338.  
  339.     swaps(&pRep->sequenceNumber, n);
  340.     swapl(&pRep->length, n);
  341.     swapl(&pRep->nEvents, n);
  342.     (void)WriteToClient(pClient, size, (char *) pRep);
  343. }
  344.  
  345. void
  346. STranslateCoordsReply(pClient, size, pRep)
  347.     ClientPtr            pClient;
  348.     int                size;
  349.     xTranslateCoordsReply    *pRep;
  350. {
  351.     int n;
  352.  
  353.     swaps(&pRep->sequenceNumber, n);
  354.     swapl(&pRep->child, n);
  355.     swaps(&pRep->dstX, n);
  356.     swaps(&pRep->dstY, n);
  357.     (void)WriteToClient(pClient, size, (char *) pRep);
  358. }
  359.  
  360. void
  361. SGetInputFocusReply(pClient, size, pRep)
  362.     ClientPtr        pClient;
  363.     int            size;
  364.     xGetInputFocusReply    *pRep;
  365. {
  366.     int n;
  367.  
  368.     swaps(&pRep->sequenceNumber, n);
  369.     swapl(&pRep->focus, n);
  370.     (void)WriteToClient(pClient, size, (char *) pRep);
  371. }
  372.  
  373. /* extra long reply */
  374. void
  375. SQueryKeymapReply(pClient, size, pRep)
  376.     ClientPtr            pClient;
  377.     int                size;
  378.     xQueryKeymapReply    *pRep;
  379. {
  380.     int n;
  381.  
  382.     swaps(&pRep->sequenceNumber, n);
  383.     swapl(&pRep->length, n);
  384.     (void)WriteToClient(pClient, size, (char *) pRep);
  385. }
  386.  
  387. static void
  388. SwapCharInfo(pInfo)
  389.     xCharInfo    *pInfo;
  390. {
  391.     register char n;
  392.  
  393.     swaps(&pInfo->leftSideBearing, n);
  394.     swaps(&pInfo->rightSideBearing, n);
  395.     swaps(&pInfo->characterWidth, n);
  396.     swaps(&pInfo->ascent, n);
  397.     swaps(&pInfo->descent, n);
  398.     swaps(&pInfo->attributes, n);
  399. }
  400.  
  401. static void
  402. SwapFontInfo(pr)
  403.     xQueryFontReply *pr;
  404. {
  405.     register char        n;
  406.  
  407.     swaps(&pr->minCharOrByte2, n);
  408.     swaps(&pr->maxCharOrByte2, n);
  409.     swaps(&pr->defaultChar, n);
  410.     swaps(&pr->nFontProps, n);
  411.     swaps(&pr->fontAscent, n);
  412.     swaps(&pr->fontDescent, n);
  413.     SwapCharInfo( &pr->minBounds);
  414.     SwapCharInfo( &pr->maxBounds);
  415.     swapl(&pr->nCharInfos, n);
  416. }
  417.  
  418. static void
  419. SwapFont( pr, hasGlyphs)
  420.     xQueryFontReply *    pr;
  421.     Bool hasGlyphs;
  422. {
  423.     unsigned    i;
  424.     xCharInfo *    pxci;
  425.     unsigned    nchars, nprops;
  426.     char    *pby;
  427.     register char n;
  428.  
  429.     swaps(&pr->sequenceNumber, n);
  430.     swapl(&pr->length, n);
  431.     nchars = pr->nCharInfos;
  432.     nprops = pr->nFontProps;
  433.     SwapFontInfo(pr);
  434.     pby = (char *) &pr[1];
  435.     /* Font properties are an atom and either an int32 or a CARD32, so
  436.      * they are always 2 4 byte values */
  437.     for(i = 0; i < nprops; i++)
  438.     {
  439.     swapl(pby, n);
  440.     pby += 4;
  441.     swapl(pby, n);
  442.     pby += 4;
  443.     }
  444.     if (hasGlyphs)
  445.     {
  446.     pxci = (xCharInfo *)pby;
  447.     for(i = 0; i< nchars; i++, pxci++)
  448.         SwapCharInfo(pxci);
  449.     }
  450. }
  451.  
  452. void
  453. SQueryFontReply(pClient, size, pRep)
  454.     ClientPtr        pClient;
  455.     int            size;
  456.     xQueryFontReply    *pRep;
  457. {
  458.     SwapFont(pRep, TRUE);
  459.     (void)WriteToClient(pClient, size, (char *) pRep);
  460. }
  461.  
  462. void
  463. SQueryTextExtentsReply(pClient, size, pRep)
  464.     ClientPtr            pClient;
  465.     int                size;
  466.     xQueryTextExtentsReply    *pRep;
  467. {
  468.     int n;
  469.  
  470.     swaps(&pRep->sequenceNumber, n);
  471.     swaps(&pRep->fontAscent, n);
  472.     swaps(&pRep->fontDescent, n);
  473.     swaps(&pRep->overallAscent, n);
  474.     swaps(&pRep->overallDescent, n);
  475.     swapl(&pRep->overallWidth, n);
  476.     swapl(&pRep->overallLeft, n);
  477.     swapl(&pRep->overallRight, n);
  478.     (void)WriteToClient(pClient, size, (char *) pRep);
  479. }
  480.  
  481. void
  482. SListFontsReply(pClient, size, pRep)
  483.     ClientPtr        pClient;
  484.     int            size;
  485.     xListFontsReply    *pRep;
  486. {
  487.     int n;
  488.  
  489.     swaps(&pRep->sequenceNumber, n);
  490.     swapl(&pRep->length, n);
  491.     swaps(&pRep->nFonts, n);
  492.     (void)WriteToClient(pClient, size, (char *) pRep);
  493. }
  494.  
  495. void
  496. SListFontsWithInfoReply(pClient, size, pRep)
  497.     ClientPtr            pClient;
  498.     int                size;
  499.     xListFontsWithInfoReply    *pRep;
  500. {
  501.     SwapFont((xQueryFontReply *)pRep, FALSE);
  502.     (void)WriteToClient(pClient, size, (char *) pRep);
  503. }
  504.  
  505. void
  506. SGetFontPathReply(pClient, size, pRep)
  507.     ClientPtr        pClient;
  508.     int            size;
  509.     xGetFontPathReply    *pRep;
  510. {
  511.     int n;
  512.  
  513.     swaps(&pRep->sequenceNumber, n);
  514.     swapl(&pRep->length, n);
  515.     swaps(&pRep->nPaths, n);
  516.     (void)WriteToClient(pClient, size, (char *) pRep);
  517. }
  518.  
  519. void
  520. SGetImageReply(pClient, size, pRep)
  521.     ClientPtr        pClient;
  522.     int            size;
  523.     xGetImageReply    *pRep;
  524. {
  525.     int n;
  526.  
  527.     swaps(&pRep->sequenceNumber, n);
  528.     swapl(&pRep->length, n);
  529.     swapl(&pRep->visual, n);
  530.     (void)WriteToClient(pClient, size, (char *) pRep);
  531.     /* Fortunately, image doesn't need swapping */
  532. }
  533.  
  534. void
  535. SListInstalledColormapsReply(pClient, size, pRep)
  536.     ClientPtr                pClient;
  537.     int                    size;
  538.     xListInstalledColormapsReply    *pRep;
  539. {
  540.     int n;
  541.  
  542.     swaps(&pRep->sequenceNumber, n);
  543.     swapl(&pRep->length, n);
  544.     swaps(&pRep->nColormaps, n);
  545.     (void)WriteToClient(pClient, size, (char *) pRep);
  546. }
  547.  
  548. void
  549. SAllocColorReply(pClient, size, pRep)
  550.     ClientPtr        pClient;
  551.     int            size;
  552.     xAllocColorReply    *pRep;
  553. {
  554.     int n;
  555.  
  556.     swaps(&pRep->sequenceNumber, n);
  557.     swaps(&pRep->red, n);
  558.     swaps(&pRep->green, n);
  559.     swaps(&pRep->blue, n);
  560.     swapl(&pRep->pixel, n);
  561.     (void)WriteToClient(pClient, size, (char *) pRep);
  562. }
  563.  
  564. void
  565. SAllocNamedColorReply(pClient, size, pRep)
  566.     ClientPtr            pClient;
  567.     int                size;
  568.     xAllocNamedColorReply    *pRep;
  569. {
  570.     int n;
  571.  
  572.     swaps(&pRep->sequenceNumber, n);
  573.     swapl(&pRep->pixel, n);
  574.     swaps(&pRep->exactRed, n);
  575.     swaps(&pRep->exactGreen, n);
  576.     swaps(&pRep->exactBlue, n);
  577.     swaps(&pRep->screenRed, n);
  578.     swaps(&pRep->screenGreen, n);
  579.     swaps(&pRep->screenBlue, n);
  580.     (void)WriteToClient(pClient, size, (char *) pRep);
  581. }
  582.  
  583. void
  584. SAllocColorCellsReply(pClient, size, pRep)
  585.     ClientPtr            pClient;
  586.     int                size;
  587.     xAllocColorCellsReply    *pRep;
  588. {
  589.     int n;
  590.  
  591.     swaps(&pRep->sequenceNumber, n);
  592.     swapl(&pRep->length, n);
  593.     swaps(&pRep->nPixels, n);
  594.     swaps(&pRep->nMasks, n);
  595.     (void)WriteToClient(pClient, size, (char *) pRep);
  596. }
  597.  
  598.  
  599. void
  600. SAllocColorPlanesReply(pClient, size, pRep)
  601.     ClientPtr            pClient;
  602.     int                size;
  603.     xAllocColorPlanesReply    *pRep;
  604. {
  605.     int n;
  606.  
  607.     swaps(&pRep->sequenceNumber, n);
  608.     swapl(&pRep->length, n);
  609.     swaps(&pRep->nPixels, n);
  610.     swapl(&pRep->redMask, n);
  611.     swapl(&pRep->greenMask, n);
  612.     swapl(&pRep->blueMask, n);
  613.     (void)WriteToClient(pClient, size, (char *) pRep);
  614. }
  615.  
  616. void
  617. SQColorsExtend(pClient, size, prgb)
  618.     ClientPtr    pClient;
  619.     int        size;
  620.     xrgb    *prgb;
  621. {
  622.     int        i, n;
  623.     xrgb    *prgbT;
  624.  
  625.     n = size / sizeof(xrgb);
  626.     prgbT = prgb;
  627.     for(i = 0; i < n; i++)
  628.     {
  629.     SwapRGB(prgbT);
  630.     prgbT++;
  631.     }
  632.     (void)WriteToClient(pClient, size, (char *) prgb);
  633. }
  634.  
  635. void
  636. SQueryColorsReply(pClient, size, pRep)
  637.     ClientPtr        pClient;
  638.     int            size;
  639.     xQueryColorsReply    *pRep;
  640. {
  641.     int n;
  642.  
  643.     swaps(&pRep->sequenceNumber, n);
  644.     swapl(&pRep->length, n);
  645.     swaps(&pRep->nColors, n);
  646.     (void)WriteToClient(pClient, size, (char *) pRep);
  647. }
  648.  
  649. void
  650. SLookupColorReply(pClient, size, pRep)
  651.     ClientPtr        pClient;
  652.     int            size;
  653.     xLookupColorReply    *pRep;
  654. {
  655.     int n;
  656.  
  657.     swaps(&pRep->sequenceNumber, n);
  658.     swaps(&pRep->exactRed, n);
  659.     swaps(&pRep->exactGreen, n);
  660.     swaps(&pRep->exactBlue, n);
  661.     swaps(&pRep->screenRed, n);
  662.     swaps(&pRep->screenGreen, n);
  663.     swaps(&pRep->screenBlue, n);
  664.     (void)WriteToClient(pClient, size, (char *) pRep);
  665. }
  666.  
  667. void
  668. SQueryBestSizeReply(pClient, size, pRep)
  669.     ClientPtr        pClient;
  670.     int            size;
  671.     xQueryBestSizeReply    *pRep;
  672. {
  673.     int n;
  674.  
  675.     swaps(&pRep->sequenceNumber, n);
  676.     swaps(&pRep->width, n);
  677.     swaps(&pRep->height, n);
  678.     (void)WriteToClient(pClient, size, (char *) pRep);
  679. }
  680.  
  681. void
  682. SListExtensionsReply(pClient, size, pRep)
  683.     ClientPtr            pClient;
  684.     int                size;
  685.     xListExtensionsReply    *pRep;
  686. {
  687.     int n;
  688.  
  689.     swaps(&pRep->sequenceNumber, n);
  690.     swapl(&pRep->length, n);
  691.     (void)WriteToClient(pClient, size, (char *) pRep);
  692. }
  693.  
  694. void
  695. SGetKeyboardMappingReply(pClient, size, pRep)
  696.     ClientPtr            pClient;
  697.     int                size;
  698.     xGetKeyboardMappingReply    *pRep;
  699. {
  700.     int n;
  701.  
  702.     swaps(&pRep->sequenceNumber, n);
  703.     swapl(&pRep->length, n);
  704.     (void)WriteToClient(pClient, size, (char *) pRep);
  705. }
  706.  
  707. void
  708. SGetPointerMappingReply(pClient, size, pRep)
  709.     ClientPtr            pClient;
  710.     int                size;
  711.     xGetPointerMappingReply    *pRep;
  712. {
  713.     int n;
  714.  
  715.     swaps(&pRep->sequenceNumber, n);
  716.     swapl(&pRep->length, n);
  717.     (void)WriteToClient(pClient, size, (char *) pRep);
  718. }
  719.  
  720. void
  721. SGetModifierMappingReply(pClient, size, pRep)
  722.     ClientPtr            pClient;
  723.     int                size;
  724.     xGetModifierMappingReply    *pRep;
  725. {
  726.     int n;
  727.  
  728.     swaps(&pRep->sequenceNumber, n);
  729.     swapl(&pRep->length, n);
  730.     (void)WriteToClient(pClient, size, (char *) pRep);
  731. }
  732.  
  733. void
  734. SGetKeyboardControlReply(pClient, size, pRep)
  735.     ClientPtr            pClient;
  736.     int                size;
  737.     xGetKeyboardControlReply    *pRep;
  738. {
  739.     int n;
  740.  
  741.     swaps(&pRep->sequenceNumber, n);
  742.     swapl(&pRep->length, n);
  743.     swapl(&pRep->ledMask, n);
  744.     swaps(&pRep->bellPitch, n);
  745.     swaps(&pRep->bellDuration, n);
  746.     (void)WriteToClient(pClient, size, (char *) pRep);
  747. }
  748.  
  749. void
  750. SGetPointerControlReply(pClient, size, pRep)
  751.     ClientPtr            pClient;
  752.     int                size;
  753.     xGetPointerControlReply    *pRep;
  754. {
  755.     int n;
  756.  
  757.     swaps(&pRep->sequenceNumber, n);
  758.     swaps(&pRep->accelNumerator, n);
  759.     swaps(&pRep->accelDenominator, n);
  760.     swaps(&pRep->threshold, n);
  761.     (void)WriteToClient(pClient, size, (char *) pRep);
  762. }
  763.  
  764. void
  765. SGetScreenSaverReply(pClient, size, pRep)
  766.     ClientPtr            pClient;
  767.     int                size;
  768.     xGetScreenSaverReply    *pRep;
  769. {
  770.     int n;
  771.  
  772.     swaps(&pRep->sequenceNumber, n);
  773.     swaps(&pRep->timeout, n);
  774.     swaps(&pRep->interval, n);
  775.     (void)WriteToClient(pClient, size, (char *) pRep);
  776. }
  777.  
  778. void
  779. SLHostsExtend(pClient, size, buf)
  780.     ClientPtr        pClient;
  781.     int            size;
  782.     char        *buf;
  783. {
  784.     char *bufT = buf;
  785.     char *endbuf = buf + size;
  786.     while (bufT < endbuf) {
  787.     xHostEntry *host = (xHostEntry *) bufT;
  788.     int len = host->length;
  789.         int n;
  790.     swaps (&host->length, n);
  791.     bufT += sizeof (xHostEntry) + (((len + 3) >> 2) << 2);
  792.     }
  793.     (void)WriteToClient (pClient, size, buf);
  794. }
  795.  
  796. void
  797. SListHostsReply(pClient, size, pRep)
  798.     ClientPtr        pClient;
  799.     int            size;
  800.     xListHostsReply    *pRep;
  801. {
  802.     int n;
  803.  
  804.     swaps(&pRep->sequenceNumber, n);
  805.     swapl(&pRep->length, n);
  806.     swaps(&pRep->nHosts, n);
  807.     (void)WriteToClient(pClient, size, (char *) pRep);
  808. }
  809.  
  810.  
  811.  
  812. void
  813. SErrorEvent(from, to)
  814.     xError    *from, *to;
  815. {
  816.     to->type = X_Error;
  817.     to->errorCode = from->errorCode;
  818.     cpswaps(from->sequenceNumber, to->sequenceNumber);
  819.     cpswapl(from->resourceID, to->resourceID);
  820.     cpswaps(from->minorCode, to->minorCode);
  821.     to->majorCode = from->majorCode;
  822. }
  823.  
  824. void
  825. SKeyButtonPtrEvent(from, to)
  826.     xEvent    *from, *to;
  827. {
  828.     to->u.u.type = from->u.u.type;
  829.     to->u.u.detail = from->u.u.detail;
  830.     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  831.     cpswapl(from->u.keyButtonPointer.time,
  832.         to->u.keyButtonPointer.time);
  833.     cpswapl(from->u.keyButtonPointer.root,
  834.         to->u.keyButtonPointer.root);
  835.     cpswapl(from->u.keyButtonPointer.event,
  836.         to->u.keyButtonPointer.event);
  837.     cpswapl(from->u.keyButtonPointer.child,
  838.         to->u.keyButtonPointer.child);
  839.     cpswaps(from->u.keyButtonPointer.rootX,
  840.         to->u.keyButtonPointer.rootX);
  841.     cpswaps(from->u.keyButtonPointer.rootY,
  842.     to->u.keyButtonPointer.rootY);
  843.     cpswaps(from->u.keyButtonPointer.eventX,
  844.         to->u.keyButtonPointer.eventX);
  845.     cpswaps(from->u.keyButtonPointer.eventY,
  846.         to->u.keyButtonPointer.eventY);
  847.     cpswaps(from->u.keyButtonPointer.state,
  848.         to->u.keyButtonPointer.state);
  849.     to->u.keyButtonPointer.sameScreen = 
  850.     from->u.keyButtonPointer.sameScreen;
  851. }
  852.  
  853. void
  854. SEnterLeaveEvent(from, to)
  855.     xEvent    *from, *to;
  856. {
  857.     to->u.u.type = from->u.u.type;
  858.     to->u.u.detail = from->u.u.detail;
  859.     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  860.     cpswapl(from->u.enterLeave.time, to->u.enterLeave.time);
  861.     cpswapl(from->u.enterLeave.root, to->u.enterLeave.root);
  862.     cpswapl(from->u.enterLeave.event, to->u.enterLeave.event);
  863.     cpswapl(from->u.enterLeave.child, to->u.enterLeave.child);
  864.     cpswaps(from->u.enterLeave.rootX, to->u.enterLeave.rootX);
  865.     cpswaps(from->u.enterLeave.rootY, to->u.enterLeave.rootY);
  866.     cpswaps(from->u.enterLeave.eventX, to->u.enterLeave.eventX);
  867.     cpswaps(from->u.enterLeave.eventY, to->u.enterLeave.eventY);
  868.     cpswaps(from->u.enterLeave.state, to->u.enterLeave.state);
  869.     to->u.enterLeave.mode = from->u.enterLeave.mode;
  870.     to->u.enterLeave.flags = from->u.enterLeave.flags;
  871. }
  872.  
  873. void
  874. SFocusEvent(from, to)
  875.     xEvent    *from, *to;
  876. {
  877.     to->u.u.type = from->u.u.type;
  878.     to->u.u.detail = from->u.u.detail;
  879.     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  880.     cpswapl(from->u.focus.window, to->u.focus.window);
  881.     to->u.focus.mode = from->u.focus.mode;
  882. }
  883.  
  884. void
  885. SExposeEvent(from, to)
  886.     xEvent    *from, *to;
  887. {
  888.     to->u.u.type = from->u.u.type;
  889.     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  890.     cpswapl(from->u.expose.window, to->u.expose.window);
  891.     cpswaps(from->u.expose.x, to->u.expose.x);
  892.     cpswaps(from->u.expose.y, to->u.expose.y);
  893.     cpswaps(from->u.expose.width, to->u.expose.width);
  894.     cpswaps(from->u.expose.height, to->u.expose.height);
  895.     cpswaps(from->u.expose.count, to->u.expose.count);
  896. }
  897.  
  898. void
  899. SGraphicsExposureEvent(from, to)
  900.     xEvent    *from, *to;
  901. {
  902.     to->u.u.type = from->u.u.type;
  903.     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  904.     cpswapl(from->u.graphicsExposure.drawable,
  905.         to->u.graphicsExposure.drawable);
  906.     cpswaps(from->u.graphicsExposure.x, 
  907.     to->u.graphicsExposure.x);
  908.     cpswaps(from->u.graphicsExposure.y, 
  909.     to->u.graphicsExposure.y);
  910.     cpswaps(from->u.graphicsExposure.width, 
  911.     to->u.graphicsExposure.width);
  912.     cpswaps(from->u.graphicsExposure.height, 
  913.     to->u.graphicsExposure.height);
  914.     cpswaps(from->u.graphicsExposure.minorEvent,
  915.         to->u.graphicsExposure.minorEvent);
  916.     cpswaps(from->u.graphicsExposure.count,
  917.     to->u.graphicsExposure.count);
  918.     to->u.graphicsExposure.majorEvent = 
  919.         from->u.graphicsExposure.majorEvent;
  920. }
  921.  
  922. void
  923. SNoExposureEvent(from, to)
  924.     xEvent    *from, *to;
  925. {
  926.     to->u.u.type = from->u.u.type;
  927.     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  928.     cpswapl(from->u.noExposure.drawable, to->u.noExposure.drawable);
  929.     cpswaps(from->u.noExposure.minorEvent, to->u.noExposure.minorEvent);
  930.     to->u.noExposure.majorEvent = from->u.noExposure.majorEvent;
  931. }
  932.  
  933. void
  934. SVisibilityEvent(from, to)
  935.     xEvent    *from, *to;
  936. {
  937.     to->u.u.type = from->u.u.type;
  938.     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  939.     cpswapl(from->u.visibility.window, to->u.visibility.window);
  940.     to->u.visibility.state = from->u.visibility.state;
  941. }
  942.  
  943. void
  944. SCreateNotifyEvent(from, to)
  945.     xEvent    *from, *to;
  946. {
  947.     to->u.u.type = from->u.u.type;
  948.     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  949.     cpswapl(from->u.createNotify.window, to->u.createNotify.window);
  950.     cpswapl(from->u.createNotify.parent, to->u.createNotify.parent);
  951.     cpswaps(from->u.createNotify.x, to->u.createNotify.x);
  952.     cpswaps(from->u.createNotify.y, to->u.createNotify.y);
  953.     cpswaps(from->u.createNotify.width, to->u.createNotify.width);
  954.     cpswaps(from->u.createNotify.height, to->u.createNotify.height);
  955.     cpswaps(from->u.createNotify.borderWidth,
  956.         to->u.createNotify.borderWidth);
  957.     to->u.createNotify.override = from->u.createNotify.override;
  958. }
  959.  
  960. void
  961. SDestroyNotifyEvent(from, to)
  962.     xEvent    *from, *to;
  963. {
  964.     to->u.u.type = from->u.u.type;
  965.     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  966.     cpswapl(from->u.destroyNotify.event, to->u.destroyNotify.event);
  967.     cpswapl(from->u.destroyNotify.window, to->u.destroyNotify.window);
  968. }
  969.  
  970. void
  971. SUnmapNotifyEvent(from, to)
  972.     xEvent    *from, *to;
  973. {
  974.     to->u.u.type = from->u.u.type;
  975.     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  976.     cpswapl(from->u.unmapNotify.event, to->u.unmapNotify.event);
  977.     cpswapl(from->u.unmapNotify.window, to->u.unmapNotify.window);
  978.     to->u.unmapNotify.fromConfigure = from->u.unmapNotify.fromConfigure;
  979. }
  980.  
  981. void
  982. SMapNotifyEvent(from, to)
  983.     xEvent    *from, *to;
  984. {
  985.     to->u.u.type = from->u.u.type;
  986.     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  987.     cpswapl(from->u.mapNotify.event, to->u.mapNotify.event);
  988.     cpswapl(from->u.mapNotify.window, to->u.mapNotify.window);
  989.     to->u.mapNotify.override = from->u.mapNotify.override;
  990. }
  991.  
  992. void
  993. SMapRequestEvent(from, to)
  994.     xEvent    *from, *to;
  995. {
  996.     to->u.u.type = from->u.u.type;
  997.     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  998.     cpswapl(from->u.mapRequest.parent, to->u.mapRequest.parent);
  999.     cpswapl(from->u.mapRequest.window, to->u.mapRequest.window);
  1000. }
  1001.  
  1002. void
  1003. SReparentEvent(from, to)
  1004.     xEvent    *from, *to;
  1005. {
  1006.     to->u.u.type = from->u.u.type;
  1007.     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  1008.     cpswapl(from->u.reparent.event, to->u.reparent.event);
  1009.     cpswapl(from->u.reparent.window, to->u.reparent.window);
  1010.     cpswapl(from->u.reparent.parent, to->u.reparent.parent);
  1011.     cpswaps(from->u.reparent.x, to->u.reparent.x);
  1012.     cpswaps(from->u.reparent.y, to->u.reparent.y);
  1013.     to->u.reparent.override = from->u.reparent.override;
  1014. }
  1015.  
  1016. void
  1017. SConfigureNotifyEvent(from, to)
  1018.     xEvent    *from, *to;
  1019. {
  1020.     to->u.u.type = from->u.u.type;
  1021.     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  1022.     cpswapl(from->u.configureNotify.event,
  1023.         to->u.configureNotify.event);
  1024.     cpswapl(from->u.configureNotify.window,
  1025.         to->u.configureNotify.window);
  1026.     cpswapl(from->u.configureNotify.aboveSibling,
  1027.         to->u.configureNotify.aboveSibling);
  1028.     cpswaps(from->u.configureNotify.x, to->u.configureNotify.x);
  1029.     cpswaps(from->u.configureNotify.y, to->u.configureNotify.y);
  1030.     cpswaps(from->u.configureNotify.width, to->u.configureNotify.width);
  1031.     cpswaps(from->u.configureNotify.height,
  1032.         to->u.configureNotify.height);
  1033.     cpswaps(from->u.configureNotify.borderWidth,
  1034.         to->u.configureNotify.borderWidth);
  1035.     to->u.configureNotify.override = from->u.configureNotify.override;
  1036. }
  1037.  
  1038. void
  1039. SConfigureRequestEvent(from, to)
  1040.     xEvent    *from, *to;
  1041. {
  1042.     to->u.u.type = from->u.u.type;
  1043.     to->u.u.detail = from->u.u.detail;  /* actually stack-mode */
  1044.     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  1045.     cpswapl(from->u.configureRequest.parent,
  1046.         to->u.configureRequest.parent);
  1047.     cpswapl(from->u.configureRequest.window,
  1048.         to->u.configureRequest.window);
  1049.     cpswapl(from->u.configureRequest.sibling,
  1050.         to->u.configureRequest.sibling);
  1051.     cpswaps(from->u.configureRequest.x, to->u.configureRequest.x);
  1052.     cpswaps(from->u.configureRequest.y, to->u.configureRequest.y);
  1053.     cpswaps(from->u.configureRequest.width,
  1054.         to->u.configureRequest.width);
  1055.     cpswaps(from->u.configureRequest.height,
  1056.         to->u.configureRequest.height);
  1057.     cpswaps(from->u.configureRequest.borderWidth,
  1058.         to->u.configureRequest.borderWidth);
  1059.     cpswaps(from->u.configureRequest.valueMask,
  1060.         to->u.configureRequest.valueMask);
  1061. }
  1062.  
  1063.  
  1064. void
  1065. SGravityEvent(from, to)
  1066.     xEvent    *from, *to;
  1067. {
  1068.     to->u.u.type = from->u.u.type;
  1069.     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  1070.     cpswapl(from->u.gravity.event, to->u.gravity.event);
  1071.     cpswapl(from->u.gravity.window, to->u.gravity.window);
  1072.     cpswaps(from->u.gravity.x, to->u.gravity.x);
  1073.     cpswaps(from->u.gravity.y, to->u.gravity.y);
  1074. }
  1075.  
  1076. void
  1077. SResizeRequestEvent(from, to)
  1078.     xEvent    *from, *to;
  1079. {
  1080.     to->u.u.type = from->u.u.type;
  1081.     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  1082.     cpswapl(from->u.resizeRequest.window, to->u.resizeRequest.window);
  1083.     cpswaps(from->u.resizeRequest.width, to->u.resizeRequest.width);
  1084.     cpswaps(from->u.resizeRequest.height, to->u.resizeRequest.height);
  1085. }
  1086.  
  1087. void
  1088. SCirculateEvent(from, to)
  1089.     xEvent    *from, *to;
  1090. {
  1091.     to->u.u.type = from->u.u.type;
  1092.     to->u.u.detail = from->u.u.detail;
  1093.     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  1094.     cpswapl(from->u.circulate.event, to->u.circulate.event);
  1095.     cpswapl(from->u.circulate.window, to->u.circulate.window);
  1096.     cpswapl(from->u.circulate.parent, to->u.circulate.parent);
  1097.     to->u.circulate.place = from->u.circulate.place;
  1098. }
  1099.  
  1100. void
  1101. SPropertyEvent(from, to)
  1102.     xEvent    *from, *to;
  1103. {
  1104.     to->u.u.type = from->u.u.type;
  1105.     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  1106.     cpswapl(from->u.property.window, to->u.property.window);
  1107.     cpswapl(from->u.property.atom, to->u.property.atom);
  1108.     cpswapl(from->u.property.time, to->u.property.time);
  1109.     to->u.property.state = from->u.property.state;
  1110. }
  1111.  
  1112. void
  1113. SSelectionClearEvent(from, to)
  1114.     xEvent    *from, *to;
  1115. {
  1116.     to->u.u.type = from->u.u.type;
  1117.     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  1118.     cpswapl(from->u.selectionClear.time, to->u.selectionClear.time);
  1119.     cpswapl(from->u.selectionClear.window, to->u.selectionClear.window);
  1120.     cpswapl(from->u.selectionClear.atom, to->u.selectionClear.atom);
  1121. }
  1122.  
  1123. void
  1124. SSelectionRequestEvent(from, to)
  1125.     xEvent    *from, *to;
  1126. {
  1127.     to->u.u.type = from->u.u.type;
  1128.     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  1129.     cpswapl(from->u.selectionRequest.time, to->u.selectionRequest.time);
  1130.     cpswapl(from->u.selectionRequest.owner,
  1131.         to->u.selectionRequest.owner);
  1132.     cpswapl(from->u.selectionRequest.requestor,
  1133.     to->u.selectionRequest.requestor);
  1134.     cpswapl(from->u.selectionRequest.selection,
  1135.     to->u.selectionRequest.selection);
  1136.     cpswapl(from->u.selectionRequest.target,
  1137.         to->u.selectionRequest.target);
  1138.     cpswapl(from->u.selectionRequest.property,
  1139.     to->u.selectionRequest.property);
  1140. }
  1141.  
  1142. void
  1143. SSelectionNotifyEvent(from, to)
  1144.     xEvent    *from, *to;
  1145. {
  1146.     to->u.u.type = from->u.u.type;
  1147.     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  1148.     cpswapl(from->u.selectionNotify.time, to->u.selectionNotify.time);
  1149.     cpswapl(from->u.selectionNotify.requestor,
  1150.     to->u.selectionNotify.requestor);
  1151.     cpswapl(from->u.selectionNotify.selection,
  1152.     to->u.selectionNotify.selection);
  1153.     cpswapl(from->u.selectionNotify.target,
  1154.     to->u.selectionNotify.target);
  1155.     cpswapl(from->u.selectionNotify.property,
  1156.         to->u.selectionNotify.property);
  1157. }
  1158.  
  1159. void
  1160. SColormapEvent(from, to)
  1161.     xEvent    *from, *to;
  1162. {
  1163.     to->u.u.type = from->u.u.type;
  1164.     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  1165.     cpswapl(from->u.colormap.window, to->u.colormap.window);
  1166.     cpswapl(from->u.colormap.colormap, to->u.colormap.colormap);
  1167.     to->u.colormap.new = from->u.colormap.new;
  1168.     to->u.colormap.state = from->u.colormap.state;
  1169. }
  1170.  
  1171. void
  1172. SMappingEvent(from, to)
  1173.     xEvent    *from, *to;
  1174. {
  1175.     to->u.u.type = from->u.u.type;
  1176.     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  1177.     to->u.mappingNotify.request = from->u.mappingNotify.request;
  1178.     to->u.mappingNotify.firstKeyCode =
  1179.     from->u.mappingNotify.firstKeyCode;
  1180.     to->u.mappingNotify.count = from->u.mappingNotify.count;
  1181. }
  1182.  
  1183. void
  1184. SClientMessageEvent(from, to)
  1185.     xEvent    *from, *to;
  1186. {
  1187.     to->u.u.type = from->u.u.type;
  1188.     to->u.u.detail = from->u.u.detail;  /* actually format */
  1189.     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  1190.     cpswapl(from->u.clientMessage.window, to->u.clientMessage.window);
  1191.     cpswapl(from->u.clientMessage.u.l.type, 
  1192.         to->u.clientMessage.u.l.type);
  1193.     switch (from->u.u.detail) {
  1194.        case 8:
  1195.           bcopy(from->u.clientMessage.u.b.bytes,
  1196.         to->u.clientMessage.u.b.bytes, 20);
  1197.       break;
  1198.        case 16:
  1199.       cpswaps(from->u.clientMessage.u.s.shorts0,
  1200.          to->u.clientMessage.u.s.shorts0);
  1201.       cpswaps(from->u.clientMessage.u.s.shorts1,
  1202.          to->u.clientMessage.u.s.shorts1);
  1203.       cpswaps(from->u.clientMessage.u.s.shorts2,
  1204.          to->u.clientMessage.u.s.shorts2);
  1205.       cpswaps(from->u.clientMessage.u.s.shorts3,
  1206.          to->u.clientMessage.u.s.shorts3);
  1207.       cpswaps(from->u.clientMessage.u.s.shorts4,
  1208.          to->u.clientMessage.u.s.shorts4);
  1209.       cpswaps(from->u.clientMessage.u.s.shorts5,
  1210.          to->u.clientMessage.u.s.shorts5);
  1211.       cpswaps(from->u.clientMessage.u.s.shorts6,
  1212.          to->u.clientMessage.u.s.shorts6);
  1213.       cpswaps(from->u.clientMessage.u.s.shorts7,
  1214.          to->u.clientMessage.u.s.shorts7);
  1215.       cpswaps(from->u.clientMessage.u.s.shorts8,
  1216.          to->u.clientMessage.u.s.shorts8);
  1217.       cpswaps(from->u.clientMessage.u.s.shorts9,
  1218.          to->u.clientMessage.u.s.shorts9);
  1219.       break;
  1220.        case 32:
  1221.       cpswapl(from->u.clientMessage.u.l.longs0,
  1222.          to->u.clientMessage.u.l.longs0);
  1223.       cpswapl(from->u.clientMessage.u.l.longs1,
  1224.          to->u.clientMessage.u.l.longs1);
  1225.       cpswapl(from->u.clientMessage.u.l.longs2,
  1226.          to->u.clientMessage.u.l.longs2);
  1227.       cpswapl(from->u.clientMessage.u.l.longs3,
  1228.          to->u.clientMessage.u.l.longs3);
  1229.       cpswapl(from->u.clientMessage.u.l.longs4,
  1230.          to->u.clientMessage.u.l.longs4);
  1231.       break;
  1232.        }
  1233. }
  1234.  
  1235. void
  1236. SKeymapNotifyEvent(from, to)
  1237.     xEvent    *from, *to;
  1238. {
  1239.     /* Keymap notify events are special; they have no
  1240.        sequence number field, and contain entirely 8-bit data */
  1241.     *to = *from;
  1242. }
  1243.  
  1244. void
  1245. WriteSConnectionInfo(pClient, size, pInfo)
  1246.     ClientPtr        pClient;
  1247.     unsigned long    size;
  1248.     char         *pInfo;
  1249. {
  1250.     int        i, j, k;
  1251.     ScreenPtr    pScreen;
  1252.     DepthPtr    pDepth;
  1253.     char    *pInfoT, *pInfoTBase;
  1254.     xConnSetup    *pConnSetup = (xConnSetup *)pInfo;
  1255.  
  1256.     pInfoT = pInfoTBase = (char *) ALLOCATE_LOCAL(size);
  1257.     if (!pInfoTBase)
  1258.     {
  1259.     pClient->noClientException = -1;
  1260.     return;
  1261.     }
  1262.     SwapConnSetup(pConnSetup, (xConnSetup *)pInfoT);
  1263.     pInfo += sizeof(xConnSetup);
  1264.     pInfoT += sizeof(xConnSetup);
  1265.  
  1266.     /* Copy the vendor string */
  1267.     i = (pConnSetup->nbytesVendor + 3) & ~3;
  1268.     bcopy(pInfo, pInfoT, i);
  1269.     pInfo += i;
  1270.     pInfoT += i;
  1271.  
  1272.     /* The Pixmap formats don't need to be swapped, just copied. */
  1273.     i = sizeof(xPixmapFormat) * screenInfo.numPixmapFormats;
  1274.     bcopy(pInfo, pInfoT, i);
  1275.     pInfo += i;
  1276.     pInfoT += i;
  1277.  
  1278.     for(i = 0; i < screenInfo.numScreens; i++)
  1279.     {
  1280.     pScreen = screenInfo.screens[i];
  1281.     SwapWinRoot((xWindowRoot *)pInfo, (xWindowRoot *)pInfoT);
  1282.     pInfo += sizeof(xWindowRoot);
  1283.     pInfoT += sizeof(xWindowRoot);
  1284.     pDepth = pScreen->allowedDepths;
  1285.     for(j = 0; j < pScreen->numDepths; j++, pDepth++)
  1286.     {
  1287.             ((xDepth *)pInfoT)->depth = ((xDepth *)pInfo)->depth;
  1288.         cpswaps(((xDepth *)pInfo)->nVisuals, ((xDepth *)pInfoT)->nVisuals);
  1289.         pInfo += sizeof(xDepth);
  1290.         pInfoT += sizeof(xDepth);
  1291.         for(k = 0; k < pDepth->numVids; k++)
  1292.         {
  1293.         SwapVisual((xVisualType *)pInfo, (xVisualType *)pInfoT);
  1294.         pInfo += sizeof(xVisualType);
  1295.         pInfoT += sizeof(xVisualType);
  1296.         }
  1297.     }
  1298.     }
  1299.     (void)WriteToClient(pClient, (int)size, (char *) pInfoTBase);
  1300.     DEALLOCATE_LOCAL(pInfoTBase);
  1301. }
  1302.  
  1303. void
  1304. SwapConnSetup(pConnSetup, pConnSetupT)
  1305.     xConnSetup     *pConnSetup, *pConnSetupT;
  1306. {
  1307.     cpswapl(pConnSetup->release, pConnSetupT->release);
  1308.     cpswapl(pConnSetup->ridBase, pConnSetupT->ridBase);
  1309.     cpswapl(pConnSetup->ridMask, pConnSetupT->ridMask);
  1310.     cpswapl(pConnSetup->motionBufferSize, pConnSetupT->motionBufferSize);
  1311.     cpswaps(pConnSetup->nbytesVendor, pConnSetupT->nbytesVendor);
  1312.     cpswaps(pConnSetup->maxRequestSize, pConnSetupT->maxRequestSize);
  1313.     pConnSetupT->minKeyCode = pConnSetup->minKeyCode;
  1314.     pConnSetupT->maxKeyCode = pConnSetup->maxKeyCode;
  1315.     pConnSetupT->numRoots = pConnSetup->numRoots;
  1316.     pConnSetupT->numFormats = pConnSetup->numFormats;
  1317.     pConnSetupT->imageByteOrder = pConnSetup->imageByteOrder;
  1318.     pConnSetupT->bitmapBitOrder = pConnSetup->bitmapBitOrder;
  1319.     pConnSetupT->bitmapScanlineUnit = pConnSetup->bitmapScanlineUnit;
  1320.     pConnSetupT->bitmapScanlinePad = pConnSetup->bitmapScanlinePad;
  1321. }
  1322.  
  1323. void
  1324. SwapWinRoot(pRoot, pRootT)
  1325.     xWindowRoot    *pRoot, *pRootT;
  1326. {
  1327.     cpswapl(pRoot->windowId, pRootT->windowId);
  1328.     cpswapl(pRoot->defaultColormap, pRootT->defaultColormap);
  1329.     cpswapl(pRoot->whitePixel, pRootT->whitePixel);
  1330.     cpswapl(pRoot->blackPixel, pRootT->blackPixel);
  1331.     cpswapl(pRoot->currentInputMask, pRootT->currentInputMask);
  1332.     cpswaps(pRoot->pixWidth, pRootT->pixWidth);
  1333.     cpswaps(pRoot->pixHeight, pRootT->pixHeight);
  1334.     cpswaps(pRoot->mmWidth, pRootT->mmWidth);
  1335.     cpswaps(pRoot->mmHeight, pRootT->mmHeight);
  1336.     cpswaps(pRoot->minInstalledMaps, pRootT->minInstalledMaps);
  1337.     cpswaps(pRoot->maxInstalledMaps, pRootT->maxInstalledMaps);
  1338.     cpswapl(pRoot->rootVisualID, pRootT->rootVisualID);
  1339.     pRootT->backingStore = pRoot->backingStore;
  1340.     pRootT->saveUnders = pRoot->saveUnders;
  1341.     pRootT->rootDepth = pRoot->rootDepth;
  1342.     pRootT->nDepths = pRoot->nDepths;
  1343. }
  1344.  
  1345. void
  1346. SwapVisual(pVis, pVisT)
  1347.     xVisualType     *pVis, *pVisT;
  1348. {
  1349.     cpswapl(pVis->visualID, pVisT->visualID);
  1350.     pVisT->class = pVis->class;
  1351.     pVisT->bitsPerRGB = pVis->bitsPerRGB;
  1352.     cpswaps(pVis->colormapEntries, pVisT->colormapEntries);
  1353.     cpswapl(pVis->redMask, pVisT->redMask);
  1354.     cpswapl(pVis->greenMask, pVisT->greenMask);
  1355.     cpswapl(pVis->blueMask, pVisT->blueMask);
  1356. }
  1357.  
  1358. void
  1359. WriteSConnSetupPrefix(pClient, pcsp)
  1360.     ClientPtr        pClient;
  1361.     xConnSetupPrefix    *pcsp;
  1362. {
  1363.     xConnSetupPrefix    cspT;
  1364.  
  1365.     cspT.success = pcsp->success;
  1366.     cspT.lengthReason = pcsp->lengthReason;
  1367.     cpswaps(pcsp->majorVersion, cspT.majorVersion);
  1368.     cpswaps(pcsp->minorVersion, cspT.minorVersion);
  1369.     cpswaps(pcsp->length, cspT.length);
  1370.     (void)WriteToClient(pClient, sizeof(cspT), (char *) &cspT);
  1371. }
  1372.  
  1373.